#!/usr/bin/env node
const log = console.log;

let buf1 = Buffer.alloc(256);
buf1[0]  = 0;

for(let i=0; i<buf1.length; i++) buf1[i] = i;
log('\nbuf1:', buf1);
 let buf2 = buf1.slice(246, 256);
log('\nbuf2:', buf2);
buf2.fill(0);
log('\nbuf2:', buf2);
log('\nbuf2\'s JSON:', buf2.toJSON());
log('\nbuf2\'s JSON:', JSON.stringify(buf2));

let array = ['a', 0xba, 0xdf, 0x00, 255, 10];
let buf3  = Buffer.from(array);
log('\nbuf3:', buf3.length, buf3);
let buf4 = Buffer.from('hello world', 'utf8');log('\nbuf4:', buf4.length, buf4);
 buf4.copy(buf3, 0, 0, buf3.length);
log('\nbuf3:', buf3.length, buf3);

